package com.cc.mall.controller;

import java.util.Arrays;
import java.util.Map;

import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.cc.mall.entity.ProductDetailEntity;
import com.cc.mall.service.ProductDetailService;
import com.cc.common.utils.R;



/**
 * 
 *
 * @author leifengyang
 * @email leifengyang@gmail.com
 * @date 2020-12-11 15:11:54
 */
@RestController
@RequestMapping("mall/productdetail")
@Api(tags = "商品详情")
public class ProductDetailController {
    @Autowired
    private ProductDetailService productDetailService;

    /**
     * 列表
     */


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		ProductDetailEntity productDetail = productDetailService.getById(id);
        return R.ok().put("productDetail", productDetail);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody ProductDetailEntity productDetail){
		productDetailService.save(productDetail);
        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody ProductDetailEntity productDetail){
		productDetailService.updateById(productDetail);
        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		productDetailService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
